package pub.tbc.atps;

import lombok.extern.slf4j.Slf4j;
import pub.tbc.atps.config.PropConfig;
import pub.tbc.toolkit.io.FileHelper;

/**
 * @author tbc on 2016/12/3 22:48.
 */
@Slf4j
public class Banner {

    private static final String DEFAULT_BANNER =
            "                       .::::.\n" +
                    "                     .::::::::.\n" +
                    "                    :::::::::::\n" +
                    "                 ..:::::::::::'\n" +
                    "              '::::::::::::'\n" +
                    "                .::::::::::\n" +
                    "           '::::::::::::::..\n" +
                    "                ..::::::::::::.\n" +
                    "              ``::::::::::::::::\n" +
                    "               ::::``:::::::::'        .:::.\n" +
                    "              ::::'   ':::::'       .::::::::.\n" +
                    "            .::::'      ::::     .:::::::'::::.\n" +
                    "           .:::'       :::::  .:::::::::' ':::::.\n" +
                    "          .::'        :::::.:::::::::'      ':::::.\n" +
                    "         .::'         ::::::::::::::'         ``::::.\n" +
                    "     ...:::           ::::::::::::'              ``::.\n" +
                    "    ```` ':.          ':::::::::'                  ::::..\n" +
                    "                       '.:::::'                    ':'````..\n" +
                    "      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
                    "                美女保佑            永无BUG";

    public static void printBanner() {
        if (PropConfig.getBoolean("banner.print", true)) {
            String banner = DEFAULT_BANNER;

            String appPath = Banner.class.getResource("/").getFile().toString();
            log.debug("系统CLASSPATH: {}", appPath);
            try {
                banner = FileHelper.readToStringByCharset(appPath + "/banner.txt");
            } catch (Exception e) {
                log.error("加载并读取banner文件失败");
            }
            System.out.println(banner);
        }
    }
}
